import common from '../store/common'

export default {

  createTextGraphic(left, top, text) {
    let graphicTextFill = "#FFF";
    if (common.getTheme() == common.THEME.LIGHT) graphicTextFill = "#262626";
    return {
      type: "text",
      z: 2,
      zlevel: 100,
      left,
      top,
      style: {
        text: text,
        textAlign: "center",
        fill: graphicTextFill,
        font: "16px 'Microsoft YaHei'"
      }
    }
  },

  createLegend({ orient, icon = "roundRect", itemWidth = 12, itemHeight = 12, itemGap = 20, left, right, top, bottom, padding, align, formatter = "{name}", fonsSize = 14, data }) {
    let legend = { icon, itemWidth, itemHeight, itemGap, formatter, textStyle: { fonsSize }, data };
    if (left != undefined) legend.left = left;
    if (right != undefined) legend.right = right;
    if (top != undefined) legend.top = top;
    if (bottom != undefined) legend.bottom = bottom;
    if (padding != undefined) legend.padding = padding;
    if (align != undefined) legend.align = align;
    if (orient != undefined) legend.orient = orient;
    return legend
  },
}